package cn.edu.sdjzu.xg.bysj.service;


import cn.edu.sdjzu.xg.bysj.dao.GraduateProjectDao;
import cn.edu.sdjzu.xg.bysj.domain.GraduateProject;
import cn.edu.sdjzu.xg.bysj.domain.GraduateProjectStatus;
import cn.edu.sdjzu.xg.bysj.domain.GraduateProjectType;
import cn.edu.sdjzu.xg.bysj.domain.Teacher;
import util.JdbcHelper;
import util.Pagination;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;

public final class GraduateProjectService {
	private GraduateProjectDao graduateProjectDao= GraduateProjectDao.getInstance();
	private static GraduateProjectService graduateProjectService = new GraduateProjectService();
	
	//Singleton
	private GraduateProjectService(){}

	public static GraduateProjectService getInstance(){
		return graduateProjectService;
	}


	public Collection<GraduateProject> findAll
			(List conditionList, Pagination pagination) throws SQLException {
		Connection connection = JdbcHelper.getConn();
		Collection<GraduateProject> graduateProjects =
				graduateProjectDao.findAll(conditionList,pagination,connection) ;
		JdbcHelper.close(connection);
		return graduateProjects;
	}

	public GraduateProject find(Integer id) throws SQLException {
		Connection connection = JdbcHelper.getConn();
		GraduateProject graduateProject = graduateProjectDao.find(id,connection);
		JdbcHelper.close(connection);
		return graduateProject;
	}

	public boolean update(GraduateProject graduateProject) throws SQLException {
		Connection connection = JdbcHelper.getConn();
		Boolean updated = graduateProjectDao.update(graduateProject,connection);
		JdbcHelper.close(connection);
		return updated ;
	}

	public boolean add(GraduateProject graduateProject) throws SQLException {
		Connection connection = JdbcHelper.getConn();
		Boolean added = graduateProjectDao.add(graduateProject,connection);
		JdbcHelper.close(connection);
		return added ;
	}
	public boolean delete(Integer id) throws SQLException{
		Connection connection = JdbcHelper.getConn();
		boolean deleted = graduateProjectDao.delete(id, connection);
		JdbcHelper.close(connection);
		return deleted;
	}

	public boolean delete(GraduateProject graduateProject) throws SQLException{
		Connection connection = JdbcHelper.getConn();
		boolean deleted = graduateProjectDao.delete(graduateProject, connection);
		JdbcHelper.close(connection);
		return deleted;
	}
}
